(function($) {
  // center a modal window
  $.fn.center = function () {
    this.css("position","absolute");
    this.css("top", ( $(window).height() - this.height() ) / 2+$(window).scrollTop() + "px");
    this.css("left", ( $(window).width() - this.width() ) / 2+$(window).scrollLeft() + "px");
    return this;
  };

  //popup
  jQuery.fn.smr_popup = function() {
    this.click(function() {
      var box = $(this).attr('href');
      $(box).center();
      $(box).fadeIn(300);
      $('body').append('<div id="mask"></div>');
      $('#mask').fadeIn(300);
      return false;
    });
    return this;
  };
  
  jQuery.fn.smr_popup_close = function() {
    this.click(function() {
      jQuery('#mask , .behang_popup').fadeOut(300 , function() {
        jQuery('#mask').remove();  
  		}); 
  		return false;
  	});
  	return this;
  }
  
      
})(jQuery);